# encoding: utf-8

import os
import sys

dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(dir_path)
sys.path.append(dir_path)

from PyQt5.Qt import *
from widget.my_window import MyWindow
from widget.root_menu import RootMenu
from widget.utils.qApp_init_props import qApp_insert_props


if __name__ == '__main__':
    import sys
    print(sys.getdefaultencoding())
    # 忽略 https verify=False 的报错
    import urllib3
    urllib3.disable_warnings()

    app = QApplication(sys.argv)

    # 挂载一些全局变量
    qApp_insert_props(qApp)
    # 挂载项目跟路径 D:\PycharmProjects\test_new_venv\widget
    qApp.cx_project_root = os.path.dirname(os.path.abspath(__file__))
    # print(current_folder)
    # 全局设置qss样式（读取对应qss文件样式表，挂载到全局类qApp中）
    with open(qApp.cx_project_root + "\\init_file\\qss\\global.qss", "r") as f1, \
            open(qApp.cx_project_root + "\\init_file\\qss\\root_menu.qss", "r") as f2, \
            open(qApp.cx_project_root + "\\init_file\\qss\\root_content.qss", "r") as f3:
        qApp.setStyleSheet(f1.read() + f2.read() + f3.read())
    # print(qApp.cx_project_root)
    # 窗口1
    window = MyWindow(width=1200, height=800)
    window.setStyleSheet(r'QWidget#home{background: url(' + qApp.cx_project_root.replace('\\', '/') + '/init_file/img/home.png);}')
    window.setWindowIcon(QIcon(qApp.cx_project_root.replace('\\', '/') + '/init_file/img/erfg.png'))

    # print('QWidget#home{background: url(' + qApp.cx_project_root.replace('\\', '/') + '/init_file/img/home.png);}')
    # 根菜单
    root_menu = RootMenu(window)
    window.show()

    # # 提示窗
    # info_box = InfoBox(info='提示内容')
    # info_box.show()

    # window.show()

    sys.exit(app.exec_())
